package com.myl.admin.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.myl.core.domain.entity.SysUser;
import com.myl.core.utils.IpUtils;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * LoginInfoVO
 * author: myl <ixiaomu@qq.com> 2024/1/11
 * tips:
 */
@Data
@NoArgsConstructor
public class LoginInfoVO implements Serializable {

    private Long clientId;

    private String uuid;

    private String nickname;

    private String username;

    private String lastIp;

    private String loginCity;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastTime;

    private String roles;

    private String menus;

    public LoginInfoVO(SysUser user) {
        this.setClientId(user.getId());
        this.setUuid("6789L-56789-67890-FGHJ0");
        this.setNickname(user.getNickname());
        this.setUsername(user.getUsername());
        this.setLastIp(user.getLastIp());
        this.setLoginCity(IpUtils.getCityInfo(user.getLastIp()));
        this.setLastTime(user.getLastTime());
        this.setRoles("admin");
    }
}
